<?php

/**
 * Error codes.
 * These error codes are used by the Controller::error() method - for easil
 * localisation in the error view.
 */
define ('ERR_NEW_ACCOUNT_FAILED', 0);
define ('ERR_NEW_ACCOUNT_LOGIN_FAILED', 1);
define ('ERR_READING_ACCOUNT', 2);
define ('ERR_COOKIE_SESSION', 3);

abstract class Controller
{
	abstract static function actionView ($data);

	static function redirect ($controller, $action='') {
		header ('Location: '.URL.'/'.$controller.'/'.$action);
	}
	
	static function error ($error, $data=null) {
		// One of the few places we exit out.  This is essentially a cleaner die();
		View::render ('error', array ('error'=>$error));
		trigger_error (print_r (array ($error, $data), true));
		exit ();
	}
}

